package com.ruoyi.web.controller.ora;

import com.alibaba.fastjson2.JSONObject;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.ora.domain.ChatRequest;
import com.ruoyi.ora.domain.ChatResponse;
import com.ruoyi.ora.service.IAiInterfaceService;
import com.ruoyi.ora.service.impl.ChatMygptlifeServiceImpl;
import com.ruoyi.ora.service.impl.SGJChatServiceImpl;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/chat")
public class ChatController extends BaseController {

    @Resource(type = SGJChatServiceImpl.class)
    private IAiInterfaceService aiInterfaceService;

    @PostMapping("/completions")
    public ChatResponse completions(@RequestBody ChatRequest chatRequest)
    {
        return aiInterfaceService.getChatCompletions(chatRequest.getMessages().get(0).getContent());
    }


    @PostMapping("/completions1")
    public ChatResponse completions1(@RequestBody ChatRequest chatRequest)
    {
        return null;
//        return aiInterfaceService.getChatCompletionsTran1(JSONObject.toJSONString(chatRequest));
    }



}
